package com.itheima.oopadvanced.codeblock;

/**
 * @author Anomaly
 * @date 2022/12/9 20:17
 */
public class BlockDemo {
    private static String name;
    private String password;

    public BlockDemo() {
        System.out.println("执行无参构造器");
    }

    public static String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public static void setName(String name) {
        BlockDemo.name = name;
    }

    public static void main(String[] args) {
        System.out.println("=========BlockDemo-main========");
        System.out.println("name = " + name);
    }

    static {
        System.out.println("========静态代码块=======");
        name = "root";
    }

    {
        System.out.println("name = \"admin\"");
        name = "admin";
        password = "123";
    }

    {
        System.out.println("name = \"user\"");
        name = "user";
    }
}
